﻿using System;
using System.Web;
using Castle.Facilities.WcfIntegration;
using Castle.Windsor;
using Castle.Windsor.Installer;

namespace Nakio.SystemAdministration.ServerHost
{
    public class Global : HttpApplication
    {
        private static IWindsorContainer container;

        protected void Application_Start(object sender, EventArgs e)
        {
            container =
               new WindsorContainer().Install(Configuration.FromXmlFile("windsor.config"));
            DefaultServiceHostFactory.RegisterContainer(container.Kernel);            
        }

        protected void Application_End(object sender, EventArgs e)
        {
            if (container != null)
            {
                container.Dispose();
            }
        }
    }
}